package com.itheima.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.domain.OmsOrderReturnReason;
import com.itheima.mapper.OmsOrderReturnReasonMapper;
import com.itheima.service.OmsOrderReturnReasonService;
import com.itheima.vo.PageBeanVo;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 退货原因表 服务实现类
 * </p>
 *
 * @author zhuguo
 * @since 2022-11-10
 */
@DubboService
public class OmsOrderReturnReasonServiceImpl  implements OmsOrderReturnReasonService {

    @Autowired
    OmsOrderReturnReasonMapper omsOrderReturnReasonMapper;

    //退货原因表分页查询
    @Override
    public PageBeanVo findByPage(int pageNum, int pageSize) {
        Page<OmsOrderReturnReason> page = new Page<>(pageNum,pageSize);

        omsOrderReturnReasonMapper.selectPage(page,null);

        return new PageBeanVo(pageNum,pageSize,page.getTotal(),page.getRecords());

    }

    //根据id获取单个退货原因详情信息
    @Override
    public OmsOrderReturnReason findInfoById(Long id) {
        return omsOrderReturnReasonMapper.selectById(id);
    }

    //修改退货原因或修改退货原因启用状态
    @Override
    public void updateReturnReason(OmsOrderReturnReason reason) {
        omsOrderReturnReasonMapper.updateById(reason);
    }

    //批量删除退货原因
    @Override
    public void deleteByIds(List<Long> ids) {
        omsOrderReturnReasonMapper.deleteBatchIds(ids);
    }

    //添加退货原因
    public void save(OmsOrderReturnReason omsOrderReturnReason) {
        omsOrderReturnReasonMapper.insert(omsOrderReturnReason);
    }
}
